From: Sebastian Keller Date: Wed, 31 Mar 2021 02:16:57 +0000 (+0200) Subject: dnd: Don't use transformed size to calculate parent scale when restoring X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~20 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e7780623fe8f1150ce0d05601db844228c6da7b2;p=gnome-shell.git dnd: Don't use transformed size to calculate parent scale when restoring Some drag actor parents might change their width to 0 after the drag actor has been removed. If the drag is now canceled and the drag actor is animated to return to the current parent position and scale, this scale can not be determined and falls back to 1.0. This might be wrong and can result in the drag actor being too large/small at the end of the return animation. To avoid this calculate the scale of the parent by recursively calculating the product of its parents individual scales. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4017 Part-of: --- diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 03b56915f..4f2910da9 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -56,6 +56,15 @@ function _getEventHandlerActor() { return eventHandlerActor; } +function _getRealActorScale(actor) { + let scale = 1.0; + while (actor) { + scale *= actor.scale_x; + actor = actor.get_parent(); + } + return scale; +} + function addDragMonitor(monitor) { dragMonitors.push(monitor); } @@ -659,11 +668,7 @@ var _Draggable = class _Draggable { // its parent, adjusting for the fact that the parent // may have been moved or scaled let [parentX, parentY] = this._dragOrigParent.get_transformed_position(); - let [parentWidth] = this._dragOrigParent.get_size(); - let [parentScaledWidth] = this._dragOrigParent.get_transformed_size(); - let parentScale = 1.0; - if (parentWidth != 0) - parentScale = parentScaledWidth / parentWidth; + let parentScale = _getRealActorScale(this._dragOrigParent); x = parentX + parentScale * this._dragOrigX; y = parentY + parentScale * this._dragOrigY;